import 'package:flutter/material.dart';

class SwichApp extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _MyState();
  }
}

class _MyState extends State<SwichApp> {
  bool swich = false;
  bool checkbox = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('SwichApp'),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            Switch(
              value: swich,
              onChanged: (value){
                setState(() {
                  swich=value;
                });
              },
            ),
            Checkbox(
              value: checkbox,
              onChanged: (value){
                setState(() {
                  checkbox=value;
                });
              },
            ),
            Switch(
              value: swich,
              onChanged: (value){
                setState(() {
                  swich=value;
                });
              },
              activeColor: Colors.red,//打开时,原点的颜色
              activeTrackColor: Colors.green,//打开时线条的颜色
              inactiveThumbColor: Colors.orange,//关闭时,原点的颜色
            ),
            Checkbox(
              value: checkbox,
              onChanged: (value){
                setState(() {
                  checkbox=value;
                });
              },
              activeColor: Colors.red,
            ),
          ],
        ),
      ),
    );
  }
}
